package mya.mes.mdc.mqtt;

import mya.mes.mdc.share.vo.mqtt.MqttMsgReceived;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedTransferQueue;


public class MqttReceivedQueue {

    private final BlockingQueue<MqttMsgReceived> queue = new LinkedTransferQueue<>();
    public void add(MqttMsgReceived msg) throws Exception {
//        System.out.println("add ---------------- queue size:"+queue.size());
        queue.put(msg);
    }

    public MqttMsgReceived take() throws Exception {
//        System.out.println("take ---------------- queue size:"+queue.size());
        return queue.take();
    }

    public void size(){
        System.out.println(queue.size());
    }
}
